Welcome Guest | Sign in | Register
Java Basics - Java Programming Interview Questions and Answers | LucentBlackBoard | LucentBlackBoard.com

Home > Technical Interviews > Computer Science & Engineering > Java Programming > Java Basics Questions and Answers

16. If I do not provide any arguments on the command line, then the String array of main() method will be empty or null?

It is empty. But not null.

17. How can one prove that the array is not null but empty using one line of code?

Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.

18. What environment variables do I need to set on my machine in order to be able to run Java programs?

CLASSPATH and PATH are the two variables.

19. Can an application have multiple classes having main() method?

Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned.


Hence there is not conflict amongst the multiple classes having main() method.

20. Can I have multiple main() methods in the same class?

No the program fails to compile. The compiler says that the main() method is already defined in the class.




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.